package com.imooc.girl.repository;

import com.imooc.girl.domain.StuInfo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import org.springframework.data.jpa.repository.Query;

import java.util.List;


public interface Stu_infoRepository extends JpaRepository<StuInfo,String>,JpaSpecificationExecutor<StuInfo>{
    @Query(value = "select s.stuName,s.major,s.stuClass,s.id,s.sex,s.phone,s.nation,s.hometown,s.dorm,s.door from StuInfo s where s.stuClass like concat(?1,'%')",
            countQuery = "select count(s.stuName) from StuInfo s where s.stuClass like concat(?1,'%')")
    Page<Object[]> findByStuClass(String id, Pageable pageable);
    @Query("select s.stuName,s.major,s.stuClass,s.id,s.sex,s.phone,s.nation,s.hometown,s.dorm,s.door from StuInfo s where s.id = ?1")
    List<Object[]> findOneById(String Id);
    @Query(value = "select min(stuClass) from StuInfo")
    Object findClassBy();
    @Query(value = "select min(stuClass) from StuInfo s where s.major = ?1")
    Object findClassByMajor(String major);
}